class Grep
  def self.grep( pattern, filename )
    matches = []
    
    regexp = Regexp.new( pattern )
    File.open(filename) do |file|
      file.each do |line|
        matches << "#{filename} #{file.lineno.to_s}: #{line}" if regexp.match(line)
      end
    end
    
    matches
  end
end

